package com.qianji.service.impl;

import com.qianji.mapper.RevenueMapper;
import com.qianji.pojo.AdparticularsDto;
import com.qianji.pojo.MediaDto;
import com.qianji.service.RevenueService;
import com.qianji.utils.Result;
import com.qianji.vo.AdvertisementVO;
import com.qianji.vo.MediaVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by 阳家桂 on 2021/3/29 14:20
 */

@Service
public class RevenueServiceImpl implements RevenueService {
    @Autowired
    private RevenueMapper revenueMapper;



    @Override
    public Result selectAdver(AdvertisementVO advertisementVO) {

        advertisementVO.setPage((advertisementVO.getPage()-1)*advertisementVO.getLimit());
        System.out.println("-*-*-*-*-*--*--*-*-*-*-*--*-*-*"+advertisementVO.toString());
        List<AdparticularsDto> list = revenueMapper.selectAdver(advertisementVO);
        Long count = revenueMapper.count(advertisementVO);
        return Result.success(list,count);
    }



    @Override
    public Result adverDaily(AdvertisementVO advertisementVO) {
        advertisementVO.setPage((advertisementVO.getPage()-1)*advertisementVO.getLimit());
        System.out.println("-*-*-*-*-*--*--*-*-*-*-*--*-*-*"+advertisementVO.getId());
        List<AdparticularsDto> dailyList = revenueMapper.adverDaily(advertisementVO);
        Long count = revenueMapper.count(advertisementVO);
        return Result.success(dailyList,count);
    }

    @Override
    public Result<MediaDto> mediaDaily(MediaVO mediaVO) {
        mediaVO.setPage((mediaVO.getPage()-1)*mediaVO.getLimit());
        List<MediaDto> dailyList = revenueMapper.mediaDaily(mediaVO);
        Long count = revenueMapper.mepcount(mediaVO);
        return Result.success(dailyList,count);
    }

    @Override
    public Result selectMedia(MediaVO mediaVO) {
//        mediaVO.setPage((mediaVO.getPage()-1)*mediaVO.getLimit());
        List<MediaDto> list = revenueMapper.selectMedia(mediaVO);
        Long count = revenueMapper.mepcount(mediaVO);
        return Result.success(list,count);
    }
}
